<template>
    <div>
        <el-table :data="tableData" border style="width: 100%" height="450px">
            <el-table-column prop="order_number" label="发货单号" width="150"> </el-table-column>
            <el-table-column prop="create_time" label="创建时间" width="230"> </el-table-column>
            <el-table-column prop="client_name" label="客户名称" width="180"> </el-table-column>
            <el-table-column prop="company_adress" label="公司地址" width="180"> </el-table-column>
            <el-table-column prop="linkman" label="联系人"> </el-table-column>
            <el-table-column prop="linkman_phone" label="联系人电话"> </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button type="text" @click="update(scope.row)">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[5, 10, 15]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
        >
        </el-pagination>
    </div>
</template>

<script>
import { order } from '../../api/api';
export default {
    data() {
        return {
            tableData: [],
            total: 0,
            currentPage: 0,
            size: 10,
            page: 1
        };
    },
    methods: {
        // 获取所有运单列表
        get_all() {
            order({ params: { size: this.size, page: this.page } }).then(res => {
                this.tableData = res.data.data;
                this.total = res.data.total;
            });
        },
        // 一页多少条数据
        handleSizeChange(val) {
            cargotype({ params: { size: val, page: this.page } }).then(res => {
                this.tableData = res.data.data;
                this.total = res.data.total;
                this.size = val;
            });
        },
        // 跳转到多少页
        handleCurrentChange(val) {
            cargotype({ params: { page: val, size: this.size } }).then(res => {
                this.tableData = res.data.data;
                this.total = res.data.total;
                this.page = val;
            });
        },
        // 编辑客户
        update(row) {
            this.$router.push({
                path: '/addorder',
                query: {
                    cid: row.id,
                    order_number: row.order_number
                }
            });
        }
    },
    mounted: function() {
        this.get_all();
    }
};
</script>

<style>
</style>